<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%
	//设置无缓存
	response.addHeader("Progma","no-cache");
	response.setHeader("Cache-Control","no-cache");
	response.setDateHeader("Expires",0);
	response.setHeader("Pragma", "no-cache");   
	response.setHeader("Cache-Control", "no-store");  
	response.setHeader("Cache-Control", "must-revalidate");
%>

<!DOCTYPE html>
<html>
	<meta http-equiv="content-type" content="text/html;charset=UTF-8">
	
	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/easyui/themes/icon.css">
	
	
	<script type="text/javascript" src="<%=basePath %>js/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/easyui/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/timeformat/timeformattool.js"></script>
	<script language="javascript" type="text/javascript" src="<%=basePath %>js/My97DatePicker/WdatePicker.js"></script>
	<link rel="stylesheet" type="text/css" href="<%=basePath %>js/My97DatePicker/skin/WdatePicker.css">	
	
	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/common_main.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/main_main.css" />
	
	<link rel="stylesheet" href="<%=basePath %>css/jqueryvalidation/screen.css" type="text/css"></link>
	<script type="text/javascript" src="<%=basePath %>js/jqueryvalidation/jquery.validate.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/ajaxfileupload.js"></script>
<body>
<div id="areaForm" class="easyui-panel" title="新建项目申报" style="width:auto;padding:30px 60px;height:auto">
<%-- <input type="hidden" id="isModify" value="${not empty projectapply ? 'yes':'no' }"></input>
<input type="hidden" id="ischakan" value="${ismodify}"></input> --%>
<form id="submitform" method="post" enctype="multipart/form-data">
		<div class="config-items">
			 <div class="result-content">
					<table class="insert-tab" width="100%">
							  <tbody>
							    <tr>
							      <th width="25%">申报单位</th>
							      <td width="75%">
							      	<input type="hidden" id="id" value="${projectapply.id}"></input>
							      	<!-- <select style="width:200px" name="areaid" id="areaid"> -->
											<c:forEach items="${departments}" var="item">
												<c:choose>
													<c:when test="${sysuser.department == item.id }">
														<%-- <option value="${item.id}" selected="selected">${item.name}</option> --%>
														<input id="areaid" name="areaid" type="text" style="width:50%" value="${item.name }" disabled="disabled"/>
													</c:when>
													<c:otherwise>
														<%-- <option value="${item.id}">${item.name}</option> --%>
													</c:otherwise>
												</c:choose>
											</c:forEach>
									<!-- </select> -->
							      </td>
							    </tr>
							    <tr>
							      <th width="25%">实验室名称</th>
							      <td width="75%">
										<input id="labname" name="labname" type="text" style="width:50%" value="${projectapply.labname }"/>
							      </td>
							    </tr>
							    <tr>
							      <th width="25%">申报人</th>
							      <td width="75%">
							      		
										<c:choose>
											<c:when test="${not empty projectapply == true}">
												<input id="username" name="username" type="text" style="width:50%" value="${sysuser.username }" disabled="disabled"/>
												<input type="hidden" id="userid" value="${sysuser.id}"></input>
											</c:when>
											<c:otherwise>
												<input id="username" name="username" type="text" style="width:50%" value="${sysuser.username }" disabled="disabled"/>
												<input type="hidden" id="userid" value="${sysuser.id}"></input>
											</c:otherwise>
										</c:choose>
							      </td>
							    </tr>
							    <tr>
							      <th width="25%">申报时间</th>
							      <td width="75%">
							      	<input id="applytime" name="applytime" type="text" style="width:50%" onfocus="new WdatePicker({startDate:'%y-%M-01',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})" value="${projectapply.applytime }"/>
							      </td>
							    </tr>
							    <tr>
							      <th width="25%">申报经费</th>
							      <td width="75%">
							      	<input id="applymoney" name="applymoney" type="text" style="width:50%"  value="${projectapply.applymoney }"/>
							      </td>
							    </tr>
							    <tr>
							      <th width="25%">备注</th>
							      <td width="75%">
							      	<textarea id="remark" name="remark" rows="3"  style="width:50%">${projectapply.remark }</textarea>
							      </td>
							    </tr>

							    <tr>
							      <th width="25%">附件</th>
							      <td width="75%">
							      	<input id="attachmenttxt" name="attachmenttxt" type="text" style="width:25%" value="${projectapply.attachment }" readonly="readonly"/>
							      	<input id="attachment" name="attachment" type="file" style="width:25%" />
							      	<a id="download" href="<%=basePath %>project/download.do?file=">下载</a>
							      </td>
							    </tr>
							    
							    <tr>
							      <th width="25%">专家意见</th>
							      
							      <td width="75%">
							      	<input type="hidden" id="expertadviceid" value="${expertAdvice.id}"></input>
							      	<input type="hidden" id="expertid" value="${expertAdvice.userid}"></input>
							      	<input type="hidden" id="projectapplayid" value="${expertAdvice.projectapplayid}"></input>  
							      	<textarea id="advice" name="advice" rows="3"  style="width:50%">${expertAdvice.advice }</textarea>
							      </td>
							    </tr>
							    
							    <tr>
							      <th width="25%"></th>
							      <td width="75%">
										<span>
											<input class="btn" name="agree" id="agree" value="同意" type="button" style="width:25%;height:30px" />
											<input class="btn" name="didnotagree" id="didnotagree" value="不同意" type="button" style="width:25%;height:30px" />
										</span>							      	
							      </td>
							    </tr>
							  </tbody>
					</table>			 	
			 </div>
        </div>
</form>
</div>
</body>
</html>

<script type="text/javascript">
$(document).ready(function(){
	if($("#applytime").val() != ""){
		var data = new Date($("#applytime").val()).format("yyyy-MM-dd");
		$("#applytime").val(data) ;
	}
	
	if($("#attachmenttxt").val() == ""){
		$("#attachmenttxt").hide();
		$("#download").hide();
	}else{
		$("#download").attr("href",$("#download").attr("href")+encodeURI(encodeURI($("#attachmenttxt").val())));
	}
	
	$("#agree").click(function(){
		agree();
	})
	$("#didnotagree").click(function(){
	    didnotagree();
	})
});

//批准
function agree(){
	var data = {id:$("#expertadviceid").val(),isagree:2,advice:$("#advice").val(),userid:$("#expertid").val(),projectapplayid:$("#projectapplayid").val()};
	var postUrl = getContextPath()+"/project/updateexpertadvicetprojectapply.do";

	$.ajax({
			type : "POST",
			url : postUrl,
			dataType : "json",
			contentType : "application/json;charset=utf-8",
			data : JSON.stringify(data),
			async : false,
			success : function(returndata) {
				//alert(returndata.key);
				if(returndata.key == "pass"){
					//重新加载数据
					$.messager.alert("提示","更改成功","info");
					$("#showData").datagrid("reload");
				}
			}
	});
}

function didnotagree(){
	var data = {id:$("#expertadviceid").val(),isagree:1,advice:$("#advice").val(),userid:$("#expertid").val(),projectapplayid:$("#projectapplayid").val()};
	var postUrl = getContextPath()+"/project/updateexpertadvicetprojectapply.do";

	$.ajax({
			type : "POST",
			url : postUrl,
			dataType : "json",
			contentType : "application/json;charset=utf-8",
			data : JSON.stringify(data),
			async : false,
			success : function(returndata) {
				//alert(returndata.key);
				if(returndata.key == "pass"){
					//重新加载数据
					$.messager.alert("提示","更改成功","info");
					$("#showData").datagrid("reload");
				}
			}
	});
}

function serializeForm(form)
{
    var obj = {};
    $.each(form.serializeArray(), function (index)
    {
        if (obj[this['name']])
        {
            obj[this['name']] = obj[this['name']] + ',' + this['value'];
        }
        else
        {
            obj[this['name']] = this['value'];
        }
    }
    );
    return obj;
}
function getContextPath() {
    var pathName = document.location.pathname;
    var index = pathName.substr(1).indexOf("/");
    var result = pathName.substr(0,index+1);
    return result;
}
</script>